package com.example.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class UserServiceApi {
	@Autowired
	RestTemplate restTemplate;
	@HystrixCommand(fallbackMethod="inser")
	public String insert() {
		return restTemplate.getForEntity("http://user-service/user/cs", String.class).getBody();
	}
	@HystrixCommand(fallbackMethod="inser")//断路器自我保护功能，发生短路启用保护
	public String inserts() {
		return restTemplate.getForEntity("http://user-service1/user/cs", String.class).getBody();
	}
	public String inser() {
		return "this is error";
	}
}
